<?php
declare (strict_types = 1);

namespace app\middleware;
use think\facade\Log;

class Apilog
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        if($request->isPost()) {
            $url = $request->url();
            $postData = $request->post();
            Log::info("==================POST start");
            Log::info("url:" . $url);
            Log::inof("post data:" . json_encode($postData));
            Log::info("==================POST end");
        }
        
        
        if($request->isGet()) {
            $url = $request->url();
            $postData = $request->get();
            Log::info("==================get start");
            Log::info("url:" . $url);
            Log::inof("get data:" . json_encode($postData));
            Log::info("==================get end");
        }
        
        return $next($request);
    }
}
